/*
提交链接:https://leetcode.cn/problems/kth-largest-element-in-a-stream/description/
703. 数据流中的第 K 大元素
赖德檀 2024/12/19
*/

class KthLargest {
public:
priority_queue<int,vector<int>, greater<int>>qe;
int t;
    KthLargest(int k, vector<int>& nums) {
        t=k;
        for(int i : nums) add(i);
    }
    
    int add(int val) {
        qe.push(val);
        if(qe.size()>t) qe.pop();
        return qe.top();
    }
};

/**
 * Your KthLargest object will be instantiated and called as such:
 * KthLargest* obj = new KthLargest(k, nums);
 * int param_1 = obj->add(val);
 */